package com.axend.aerosense.user.viewmodel;

import com.axend.aerosense.base.viewmodel.BaseViewModel;
import com.axend.aerosense.common.ui.CustomUpdateDialog;

import io.reactivex.disposables.Disposable;

/**
 * Author: ChenHongWei
 * Date: 2021/2/26 10:58
 */
public class UserAboutViewModel extends BaseViewModel {

    private Disposable disposable;
    private CustomUpdateDialog updateDialog;

    /*@Autowired(name = ServicesConfig.User.LONGING_SERVICE)
    ILoginService iLoginService;

    public UserAboutViewModel(){
        ARouter.getInstance().inject(this);
    }*/

    /*public void checkUpdate(Context context){
        disposable = EasyHttp.post(UrlApi.URL.GetAppVersion.getUrl())
                .cacheMode(CacheMode.NO_CACHE)
                .upJson(JsonUtil.toJson(new BaseDevInfoBean()))
                .execute(new SimpleCallBack<UpdateAppBean>() {
                    @Override
                    public void onTokenExpire() {

                    }

                    @Override
                    public void onError(ApiException e) {
                        e.printStackTrace();
                    }

                    @Override
                    public void onSuccess(UpdateAppBean updateAppBean) {
                        showUpdateDialog(updateAppBean, context);
                        if (updateAppBean.getUpdate() == 0){
                            //不需要更新
                        }else if (updateAppBean.getUpdate() == 1){
                            if (updateAppBean.getState() == 0){

                            }
                        }
                    }
                });
    }*/

    /** 显示提示窗口 */
    /*private void showUpdateDialog(UpdateAppBean updateAppBean, Context context){
        updateDialog = new CustomUpdateDialog(context, updateAppBean.getNotice());
        updateDialog.isShowCloseBtn(updateAppBean.getState() == 0);
        updateDialog.setOnClickBottomListener(new CustomUpdateDialog.OnClickBottomListener() {
            @Override
            public void onPositiveClick() {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=com.axend.aerosense"));
                context.startActivity(intent);
            }

            @Override
            public void onNegtiveClick() {
                updateDialog.dismiss();
                if (updateAppBean.getState() == 1){
                    //TODO 退出应用
                }
            }

            @Override
            public void onCloseClick() {
                updateDialog.dismiss();
            }
        });
        updateDialog.show();
    }*/

    @Override
    public void onLoad() {

    }
}
